package cn.jinjimi.app.managers;

import java.util.HashMap;

/**
 * Created by Roy
 * 网页跳原生存储网页参数 2.6.2添加
 * Date: 2017/3/9
 */

public class NetRouteParamManager {

    private static volatile NetRouteParamManager instance = null;

    private HashMap<String, String> routerParam = new HashMap<>();

    /* 双重检验锁的懒汉模式的单例模式*/
    public static NetRouteParamManager getInstance() {
        if (instance == null) {
            synchronized (NetRouteParamManager.class) {
                if (instance == null)
                    instance = new NetRouteParamManager();
            }
        }
        return instance;
    }

    public NetRouteParamManager() {
    }

    public void addRouterParam(String param, String value) {
        if (routerParam == null)
            routerParam = new HashMap<>();

        routerParam.put(param, value);
    }

    public HashMap<String, String> getRouterParam() {
        if (routerParam == null)
            routerParam = new HashMap<>();

        return routerParam;
    }

    public void clearRouterParam() {
        if (routerParam != null)
            routerParam.clear();
    }
}
